package com.red.star.wechat.data.mappers;

import com.red.star.wechat.data.core.base.MyMapper;
import com.red.star.wechat.data.entity.DailyMerchantPoster;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.Date;
import java.util.List;

public interface DailyMerchantPosterMapper extends MyMapper<DailyMerchantPoster> {

    List<DailyMerchantPoster> getDailyMerchantPoster(DailyMerchantPoster dailyMerchantPoster);

    /**
     * 查询某一天是否有数据
     * @param time 时间(天)
     * @return 某天数据数量(大于0则有数据)
     */
    @Select("SELECT COUNT(*) AS totalCount FROM stat_daily_merchant_poster WHERE time = #{time}")
    Integer countDailyMerchantPoster(@Param("time") Date time);

    @Delete("delete from stat_daily_merchant_poster where date_format(time,'%Y-%m-%d')=#{dayTime}")
    Integer deleteByDayTime(@Param("dayTime") String dayTime);

}
